import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
public class Test {
    public static void main(String[] args) {

        ArrayList<Integer> arrayList = new ArrayList<>();
        arrayList.add(10);
        arrayList.add(12);
        arrayList.add(23);
        arrayList.add(34);
        System.out.println(arrayList);
        System.out.println("======");

        for (int i = 0; i < arrayList.size(); i++) {
            System.out.print(arrayList.get(i)+" ");
        }
        System.out.println();
        System.out.println("======");
//           此处int也可以
        for(Integer x : arrayList) {
            System.out.print(x+" ");
        }
        System.out.println();
        System.out.println("===iterator===");
        //默认是从 0 下标开始打印
        Iterator<Integer> it =  arrayList.iterator();
        while (it.hasNext()) {
            System.out.print(it.next() +" ");
        }
        System.out.println();
        System.out.println("===ListIterator===");

    }

}
